<template>
  <div class="mui-numbox" data-numbox-min="1">
    <button class="mui-btn mui-numbox-btn-minus" type="button">-</button>
    <input type="number" class="mui-numbox-input" 
      :value="initCount"
      @change="countChange"
      ref="num"
      readonly />
    <button class="mui-btn mui-numbox-btn-plus" type="button">+</button>
  </div>
</template>

<script>
import mui from '../../lib/mui/js/mui.min.js'

export default {
  name: 'shopcar-numbox',
  props: [ 'initCount', 'goodsId' ],
  mounted() {
    mui('.mui-numbox').numbox()
  },
  methods: {
    countChange() {
      this.$store.commit('updateGoodsCount', {
        id: this.goodsId,
        count: this.$refs.num.value
      })
    }
  }
}
</script>

<style lang="less" scoped>

</style>
